/**
 * 
 */
package DataBase;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Vector;

import DataObjects.Payment;
import DataObjects.TablesOfShift;

/**
 * @author Andrey
 *
 */
public class GetAllTablesOfShift {
	
	private Vector<TablesOfShift>  tables;
	
	public Vector<TablesOfShift> getTablesOfShift()
	{
		SQLConnection sc=new SQLConnection();
		
		try {
			
		PreparedStatement ps = sc.getConnection().prepareStatement("Select t.orderId,t.tid,t.no_of_persons,t.status,t.timeOpen,t.dateOpen,t.no_of_children FROM table_timeslot t,shift s where s.status='open' and s.shiftId=t.shiftId ;");	
		
		ResultSet rs=ps.executeQuery();
		tables=new Vector<TablesOfShift>();
		 while(rs.next() )
	        {   
			 TablesOfShift tab =new  TablesOfShift();
			 tab.setOrderId(rs.getInt(1));
			 tab.setTableId(rs.getInt(2));
			 tab.setQuantityOfPeople(rs.getInt(3));
			 tab.setStatus(rs.getString(4));
			 tab.setTime(rs.getString(5));
			 tab.setDateOpen(rs.getString(6));
			 tab.setQuantityOfChildren(rs.getInt(7));
			 
		
		
			 tables.add(tab);
	        }
		ps.close();
		sc.getConnection().close();
		
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return tables;
	}

}
